<template>
  <div>
    <van-nav-bar
      :title="comment.reply_count ? comment.reply_count +'条回复' : '暂无回复'"
    >
      <template #left>
        <van-icon @click="$emit('close-reply')" name="cross" />
      </template>
    </van-nav-bar>
    <div class="scroll-center">
        <commentItem :row="comment" />
        <van-cell title="全部回复"/>
        <commentList type="c" :source="comment.com_id" :list='list' />
    </div>
    <!-- 底部评论 -->
    <div class="post-warp">
        <van-button @click="isShowReplyPost = true" round>评论</van-button>
    </div>

    <van-popup v-model="isShowReplyPost" position="bottom">
      <template>
        <commentPost @on-post-success="onPostSuccess" :target="comment.com_id" :artId="$route.params.articleId" />
      </template>
    </van-popup>
  </div>
</template>

<script>
import commentItem from '@/components/comment-item'
import commentList from '@/components/comment-list'
import commentPost from './comment-post.vue'
export default {
  data () {
    return {
      list: [],
      isShowReplyPost: false
    }
  },
  props: {
    comment: {
      type: Object,
      required: true
    }
  },
  created () {

  },

  methods: {
    onPostSuccess (obj) {
      this.list.unshift(obj)
      this.isShowReplyPost = false
    }
  },
  components: {
    commentItem,
    commentList,
    commentPost
  }
}
</script>

<style lang="less" scoped>
.scroll-center{
  position: absolute;
  top: 92px;
  bottom: 102px;
  width: 100%;
  overflow-y: scroll;
}
.post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  background-color: #999;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  .van-button {
    width: 640px;
    height: 80px;
  }
}
</style>
